From 67c82e8bd9f75d36bda1d293dfe19adc1d98d9fe Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 10 Jun 2019 21:39:14 +0000 Subject: [PATCH] text view: Fix selection bubble handling We can't call gtk_widget_destroy on something that wasn't added as a child to a container - it ends up calling gtk_container_remove, which asserts if it doesn't find the child. --- gtk/gtktextview.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 865b300049..6e87b25f23 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -3635,8 +3635,7 @@ gtk_text_view_finalize (GObject *object) if (priv->bottom_window) text_window_free (priv->bottom_window); - if (priv->selection_bubble) - gtk_widget_destroy (priv->selection_bubble); + g_clear_pointer (&priv->selection_bubble, gtk_widget_unparent); if (priv->magnifier_popover) gtk_widget_destroy (priv->magnifier_popover); @@ -8796,8 +8795,7 @@ gtk_text_view_selection_bubble_popup_show (gpointer user_data) all_selected = gtk_text_iter_equal (&start, &sel_start) && gtk_text_iter_equal (&end, &sel_end); - if (priv->selection_bubble) - gtk_widget_destroy (priv->selection_bubble); + g_clear_pointer (&priv->selection_bubble, gtk_widget_unparent); priv->selection_bubble = gtk_popover_new (GTK_WIDGET (text_view)); gtk_style_context_add_class (gtk_widget_get_style_context (priv->selection_bubble), -- 2.30.2